package iotwisp.school.wx.qo;

import iotwisp.base.cqrs.BaseQO;
import iotwisp.base.orm.query.QueryCondition;
import iotwisp.base.orm.query.QueryConditionType;
import iotwisp.base.orm.query.QueryConfig;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Date;

@SuppressWarnings("serial")
@Data
@EqualsAndHashCode(callSuper = false)
@QueryConfig(daoBeanId = "wxUserService")
public class WxUserQO extends BaseQO<String> {

    @QueryCondition(name = "user", type = QueryConditionType.FETCH_EAGER)
    private boolean fetchUser;

    @QueryCondition(name = "user.id")
    private String userId;

    @QueryCondition(name = "accessToken")
    private String accessToken;
    @QueryCondition(name = "unionId")
    private String unionId;
    @QueryCondition(name = "expireDate", type = QueryConditionType.GE)
    private Date geExpireDate;
    @QueryCondition(name = "expireDate", type = QueryConditionType.LE)
    private Date leExpireDate;

    private boolean expire;

    public void isExpire(boolean expire) {
        if (expire) {
            setGeExpireDate(new Date());
        } else {
            setLeExpireDate(new Date());
        }
    }
}
